home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / g++ / Regex.h < prev    next >
C/C++ Source or Header  |  1995-02-06  |  3KB  |  78 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _Regex_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #pragma cplusplus
  24. #endif
  25. #define _Regex_h 1
  26.  
  27. #if defined(SHORT_NAMES) || defined(VMS)
  28. #define re_compile_pattern    recmppat
  29. #define re_pattern_buffer    repatbuf
  30. #define re_registers        reregs
  31. #endif
  32.  
  33. struct re_pattern_buffer;       // defined elsewhere
  34. struct re_registers;
  35.  
  36. class Regex
  37. {
  38. private:
  39.  
  40.                      Regex(const Regex&) {}  // no X(X&)
  41.   void               operator = (const Regex&) {} // no assignment
  42.  
  43. protected:
  44.   re_pattern_buffer* buf;
  45.   re_registers*      reg;
  46.  
  47. public:
  48.                      Regex(const char* t, 
  49.                            int fast = 0, 
  50.                            int bufsize = 40, 
  51.                            const char* transtable = 0);
  52.  
  53.                     ~Regex();
  54.  
  55.   int                match(const char* s, int len, int pos = 0) const;
  56.   int                search(const char* s, int len, 
  57.                             int& matchlen, int startpos = 0) const;
  58.   int                match_info(int& start, int& length, int nth = 0) const;
  59.  
  60.   int                OK() const;  // representation invariant
  61. };
  62.  
  63. // some built in regular expressions
  64.  
  65. extern const Regex RXwhite;          // = "[ \n\t\r\v\f]+"
  66. extern const Regex RXint;            // = "-?[0-9]+"
  67. extern const Regex RXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
  68.                                      //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
  69.                                      //    \\([eE][---+]?[0-9]+\\)?"
  70. extern const Regex RXalpha;          // = "[A-Za-z]+"
  71. extern const Regex RXlowercase;      // = "[a-z]+"
  72. extern const Regex RXuppercase;      // = "[A-Z]+"
  73. extern const Regex RXalphanum;       // = "[0-9A-Za-z]+"
  74. extern const Regex RXidentifier;     // = "[A-Za-z_][A-Za-z0-9_]*"
  75.  
  76.  
  77. #endif
  78.